let logo_img = document.querySelector('.logo-img');
logo_img.addEventListener('click', backHome);

function backHome() {
    location.href = "index.html"
}

const obj = {
    __timestamp: "1628607618145"
}

$('.nav-list').bind({
    mouseenter: function () {
        $(this).find('.nav-addlist').css('display', 'block');
        var index = $(this).index() - 1;
        pAjax({
            url: '/xmz',
            data: querystringify(obj),
            dataType: 'json',
        }).then(json => {
            var toplist = json.data.cateList[index].subCateGroupList
            var toplistlist = json.data.cateList[index].subCateGroupList[index].categoryList
            // console.log(toplist,toplistlist,index);
            // console.log(json.data.cateList[index]);

            var nav_dom = '<ul>'
            // console.log(toplist)
            toplist.forEach(f => {
                nav_dom += `
                <li>
                    <h3>${f.name}</h3>
                    <ol>`

                toplistlist.forEach(e => {
                    nav_dom += `
                        <li>
                            <img src="${e.bannerUrl}" style="width:50px;height:50px">
                            ${e.name}
                        </li>`
                })

                nav_dom += `
                    </ol>
                </li>`
            })
            nav_dom += `</ul>`

            // console.log(nav_dom);

            $('.nav-addlist').html(nav_dom)
        })
    },

    mouseleave: function () {
        $(this).find('.nav-addlist').css('display', 'none');}

})

$('#gotop').click(() => {
    $('html').animate({
        scrollTop: 0
    }, 1000)
})
window.onscroll = function () {
    var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
    if (scrollTop >= 300) {
        $('#gotop').css({
            display: "block",
        })
    } else {
        $('#gotop').css({
            display: "none",
        })
    }
}

